// HDU 1166

#include <bits/stdc++.h>
using namespace std;
const int N = 50010;
typedef int ll;
ll n, a[N];
ll bit[N];
inline int lowbit(int x) { return x & -x; }
void add(int c, int x) {
  for (int i = c; i <= n; i += lowbit(i)) bit[i] += x;
}
ll query(int x) {
  ll sum = 0;
  for (int i = x; i > 0; i -= lowbit(i)) sum += bit[i];
  return sum;
}
void build() {
  for (int i = 1; i <= n; ++i) bit[i] = 0;
  for (int i = 1; i <= n; ++i) add(i, a[i]);
}
int main() {
  // HDU 是少见的卡IO的OJ
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  for (int t = 1; t <= tc; ++t) {
    cout << "Case " << t << ":\n";
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    build();
    cin.get();
    while (true) {
      string op;
      cin >> op;
      if (op == "End")
        break;
      else {
        int a, b;
        cin >> a >> b;
        if (op == "Add") {
          add(a, b);
        } else if (op == "Sub") {
          add(a, -b);
        } else if (op == "Query") {
          cout << query(b) - query(a - 1) << endl;
        } else
          assert(false);
      }
    }
  }
}
